package com.neepu.serviceImpl;

import com.neepu.dao.EvaluationResultMapper;
import com.neepu.dao.UserMapper;
import com.neepu.pojo.Result;
import com.neepu.pojo.User;
import com.neepu.service.EvaluationResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("EvaluationResultService")
public class EvaluationResultServiceImpl implements EvaluationResultService {

    @Autowired
    private EvaluationResultMapper evaluationResultMapper;

    @Override
    public List<Map<String, Object>> pieData(String id) {

        List<Map<String,Object>> data =new ArrayList<>();
        List<Result> listdata=evaluationResultMapper.countS(id);
        if(listdata.size()>0){
            for(int i=0;i<listdata.size();i++){
                Map<String,Object> map=new HashMap<>();
                map.put("name", listdata.get(i).getStudentID());
                map.put("value", listdata.get(i).getScore());
                data.add(map);
            }
        }
        return data;
    }

    @Override
    public List<Map<String, Object>> pieData2(String id) {
        List<Map<String,Object>> data =new ArrayList<>();
        // 一共有多少个指标
        for (int i = 1; i < 6; i++) {
            Map<String,Object> map=new HashMap<>();
            //  第一个指标
            map.put("one",evaluationResultMapper.countScore1(i,id).getScore());  // 极差
            map.put("two",evaluationResultMapper.countScore2(i,id).getScore());  //较差
            map.put("three",evaluationResultMapper.countScore3(i,id).getScore()); //中等
            map.put("four",evaluationResultMapper.countScore4(i,id).getScore());//良好
            map.put("five",evaluationResultMapper.countScore5(i,id).getScore());//优秀
            data.add(map);
        }
        return data;
    }

    @Override
    public List<User> countTeacher() {
        return evaluationResultMapper.countTeacher();
    }
}